package org.ccay.enumerable;

import org.ccay.core.ioc.Ccay;
import org.ccay.core.util.StringUtil;
import org.ccay.i18n.service.impl.I18nResourceBundle;


/**
 * 枚举类型的国际化支持工具
 * @author chaowangbang
 *
 */
public class EnumI18nUtil {
	
	private static I18nResourceBundle resourceBundle;
	
	public static final String ENUM_I18N_PREFIXE = "Enum.";
	
	public static String  getI18nName(EnumItem item,String language){
		if(StringUtil.isNullOrEmpty(language)){
			return item.getDisplayValue();
		}
		String i18nKey = ENUM_I18N_PREFIXE + item.getType()+"."+item.getValue();
		if(resourceBundle == null){
			resourceBundle = (I18nResourceBundle)Ccay.getContext().getBean("i18nResourceBundle");
		}
		return resourceBundle.getI18nVO(i18nKey, language,item.getDisplayValue()).getI18nContent();
	}

}
